Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: VHDS: on-demand updates #6552

Closed
wants to merge 30 commits into from
Closed

WIP: VHDS: on-demand updates #6552

wants to merge 30 commits into from

Conversation

dmitri-d
Copy link
Contributor

For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md

Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
[Optional Fixes #Issue]
[Optional Deprecated:]

@dmitri-d
Copy link
Contributor Author

@dmitri-d dmitri-d changed the title VHDS: on-demand updates WIP: VHDS: on-demand updates Apr 10, 2019
@dmitri-d
Copy link
Contributor Author

@brian-avery

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, will focus on OnDemandUpdate for until we have the base patches merged.

include/envoy/router/rds.h Outdated Show resolved Hide resolved
source/common/router/on_demand_update.cc Outdated Show resolved Hide resolved
source/common/router/on_demand_update.cc Outdated Show resolved Hide resolved
source/common/router/on_demand_update.cc Outdated Show resolved Hide resolved
@stale
Copy link

stale bot commented Apr 19, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Apr 19, 2019
@stale
Copy link

stale bot commented Apr 26, 2019

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot closed this Apr 26, 2019
@htuch htuch reopened this Apr 26, 2019
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Apr 26, 2019
@stale
Copy link

stale bot commented May 3, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label May 3, 2019
@stale
Copy link

stale bot commented May 10, 2019

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@htuch htuch reopened this May 16, 2019
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label May 16, 2019
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Dmitri Dolguikh added 2 commits May 16, 2019 15:52
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@htuch htuch added the waiting label May 20, 2019
@stale
Copy link

stale bot commented May 23, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label May 23, 2019
Dmitri Dolguikh added 2 commits May 29, 2019 12:02
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label May 29, 2019
Dmitri Dolguikh added 8 commits May 29, 2019 13:42
…d docs

Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
@dmitri-d
Copy link
Contributor Author

@htuch: I think this is ready to be reviewed. Please let me know if you would like me to squash the commits (I think they'll need to be cleaned up, as the sequence of commits with respect to the base VHDS commit is out of order).

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall structure/approach looks good, a few comments, would be great to cleanup various commented code and to generally add more docs/comments. Thanks!

@@ -150,6 +150,8 @@ class StreamFilterCallbacks {
*/
virtual Router::RouteConstSharedPtr route() PURE;

virtual bool requestRouteConfigUpdate(std::function<void()> cb) PURE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add Doxygen docs for this?

@@ -79,6 +80,10 @@ class Subscription {
* be passed to std::set_difference, which must be given sorted collections.
*/
virtual void updateResources(const std::set<std::string>& update_to_these_names) PURE;

virtual void updateResourcesViaAliases(const std::set<std::string>&) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add Doxygen docs for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am perceiving the intention correctly, I think you might also want to change the name. updateResources() is kind of misnamed; it's not about getting updated resources, but rather updating the set of resource names we care about. Similarly, it looks like this one is about adding to a list of aliases, not updating resources.

...so I guess I'm really saying now would be a good time to give updateResources() a better name. Can I suggest something like either updateResourceInterest or updateSubscriptionInterest?

As for the aliases one, since it looks like it's more of a blanket addition than a "replace with this set" (which is how updateResources currently works), I would suggest like addAliases or addResourceAliases.

@@ -48,6 +48,17 @@ class RouteConfigProvider {
* Callback used to notify RouteConfigProvider about configuration changes.
*/
virtual void onConfigUpdate() PURE;

/**
* Callback used to request an update to the route configuration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An update from the management server?

* must match on
* @param cb callback to be called when the configuration update has been propagated to worker
* threads
* @return whether a request for a configuration update has been successfully scheduled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How/why can this fail?


/**
* Callback used to request an update to the route configuration.
* @param for_domain supplies the domain name that virtual hosts contained in the VHDS response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit confusing, as it is an update request, but the thing we're requesting is referencing the response..

@@ -48,6 +48,11 @@ VhdsSubscription::VhdsSubscription(RouteConfigUpdatePtr& config_update_info,
factory_context.api());
}

void VhdsSubscription::ondemandUpdate(const std::set<std::string>& aliases) {
std::cout << "11111111111111111111111111111111111\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

}

attempting_internal_redirect_with_complete_stream_ = false;
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

return false;
}
factory_context_.dispatcher().post(
[this, for_domain]() -> void { subscription_->ondemandUpdate({for_domain}); });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be onDemandUpdate..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an issue of collision with Envoy callback naming, though, right? onDemandUpdate sounds like a function that handles a "demand update". Not sure that there's a good solution here, hahaha....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe updateOnDemand? lazyUpdate?

tls_->runOnAllThreads([this, new_config]() -> void {
tls_->getTyped<ThreadLocalConfig>().config_ = new_config;
auto callbacks = config_update_callbacks_->getTyped<ThreadLocalCallbacks>().callbacks_;
if (!callbacks.empty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a while? What if there are multiple updates requested before a response is received? Do you have tests for this?


if (!callbacks_->decodingBuffer() && // Redirects with body not yet supported.
callbacks_->recreateStream()) {
// cluster_->stats().upstream_internal_redirect_succeeded_total_.inc();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@htuch htuch added the waiting label Jun 3, 2019
Copy link
Contributor

@fredlas fredlas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this fits in with both the current subscription state stuff, and my ongoing work, very nicely; basically zero friction. That's a relief! I also like where the refactoring in DeltaSubscriptionState is going.

@@ -79,6 +80,10 @@ class Subscription {
* be passed to std::set_difference, which must be given sorted collections.
*/
virtual void updateResources(const std::set<std::string>& update_to_these_names) PURE;

virtual void updateResourcesViaAliases(const std::set<std::string>&) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am perceiving the intention correctly, I think you might also want to change the name. updateResources() is kind of misnamed; it's not about getting updated resources, but rather updating the set of resource names we care about. Similarly, it looks like this one is about adding to a list of aliases, not updating resources.

...so I guess I'm really saying now would be a good time to give updateResources() a better name. Can I suggest something like either updateResourceInterest or updateSubscriptionInterest?

As for the aliases one, since it looks like it's more of a blanket addition than a "replace with this set" (which is how updateResources currently works), I would suggest like addAliases or addResourceAliases.

}

void DeltaSubscriptionState::populateDiscoveryRequest(
envoy::api::v2::DeltaDiscoveryRequest& request) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may be able to factor out the if (!any_request_sent_yet_in_current_stream_) block from populateDiscoveryRequest into its own function. Then, rather than having ifs+elses in getNextRequest(), you could just do

if (!any_request_sent_yet_in_current_stream_)
  prepareFirstRequest(request);
if (!aliases_added_.empty())
  populateWithAliases(request);
populateDiscoveryRequest(request);

@@ -76,10 +76,15 @@ void DeltaSubscriptionState::updateResourceInterest(
}
}

void DeltaSubscriptionState::updateResourceInterestViaAliases(
const std::set<std::string>& updates_to_these_aliases) {
aliases_added_.insert(updates_to_these_aliases.begin(), updates_to_these_aliases.end());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One surface-level (since I don't know how it's supposed to work) question to double check you're doing what you intend: is it your intention that aliases are only ever added, not removed? Or, it looks like the actual mechanism is that these aliases just go into resource_names_subscribe; does that mean that to remove them, you are supposed to just do a normal unsubscribe of those names?

return false;
}
factory_context_.dispatcher().post(
[this, for_domain]() -> void { subscription_->ondemandUpdate({for_domain}); });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an issue of collision with Envoy callback naming, though, right? onDemandUpdate sounds like a function that handles a "demand update". Not sure that there's a good solution here, hahaha....

@stale
Copy link

stale bot commented Jun 10, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Jun 10, 2019
@stale
Copy link

stale bot commented Jun 17, 2019

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot closed this Jun 17, 2019
@dmitri-d dmitri-d deleted the vhds-on-demand branch May 20, 2020 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale stalebot believes this issue/PR has not been touched recently waiting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants